<template>
  <div id="app" class='app'>
      <div id="main">
        <form id="login" name="login" method="post" action="#" enctype='application/json' v-on:submit="login()">
            <div class='logo'>
            </div>
            <div class='logoText'>
                深蓝系统登陆
            </div>
            <div class='account'>
                <input type="text" id="account" name="account" placeholder="账号" autocomplete="off" autofocus required oninvalid="setCustomValidity('用户名不能为空，请输入')" oninput="setCustomValidity('')"/>
            </div>
            <div class='password'>
                <input type="password" id="password" name="password" placeholder="密码" autocomplete="off" required oninvalid="setCustomValidity('密码不能为空，请输入')" oninput="setCustomValidity('')"/>
            </div>
            <div class="errormsg">
            </div>
        </form>
        <button type="submit" class="submit" form="login" ></button>
        <div class='loading hidden' id="loading">
            <div class="loadingt">
                 <div class='loadingimg'></div>
            </div>
           
        </div>
         
      </div>
     
      <div  id='bg1' ></div>
      <div id="bg2"></div>
  </div>
  
        
</template>
<script>
import Vue  from 'vue'
import '../assets/css/common.css'
export default {
  name: 'Home',
  components: {
   
  },
  data(){
      return {
         
      }
  },
  beforeCreate(){
      document.title="深蓝系统"; 
  },
  methods:{
    login(){
       var loading=document.getElementById("loading");
       var loadings=window.setTimeout(function(){
          loading.className="loading show";
       },500);
      
       event.preventDefault() //阻止form表单默认提交
        localStorage.setItem("ip","http://192.168.1.64:10025/");
        localStorage.setItem("imgIp","http://jsweixin.tianxunwang.com");
        
        this.$post('apiServe/login',
          {
              account:escape(document.getElementById("account").value),
              password:escape(document.getElementById("password").value)
          }
         //   headers:
//            {'Content-Type': 'application/json' }

        ).then(data=>{
            if(data[0].status=="err"){
                 document.getElementsByClassName("errormsg")[0].innerHTML=unescape(data[0].msg+"！")
            }else{
                window.location.href='/win10'
            }
            window.clearTimeout(loadings)
            loading.className="loading hidden"; 
        });
    }
  }
}
</script>
<style scoped  src="../assets/css/loginV1.0.css">
</style>
